package com.fl.niu.model;

import java.util.Date;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;

/**
 * 文件表
 * @author qj
 * @since 2020-11-20
 */
@TableName("sys_file")
@Data
@Builder
@EqualsAndHashCode(callSuper=false)
public class SysFile implements Serializable  {

    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.UUID)
    private String fileId;

    @TableField(value = "file_name")
    private String fileName;

    @TableField(value = "file_url")
    private String fileUrl;

    @TableField(value = "file_path")
    private String filePath;

    @TableField(value = "batch_id")
    private String batchId;

    @TableField(value = "sort")
    private int sort;

    @TableField(value = "size")
    private Integer size;

    @TableField(value = "file_type")
    private String fileType;

    @TableField(value = "update_id")
    private String updateId;

    @TableField(value = "create_id")
    private String createId;

    //视频封面
    @TableField(value = "video_cover")
    private String videoCover;

    /**
     * 创建时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "create_time")
    private Date createTime;

    /**
     * 创建时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "update_time")
    private Date updateTime;

    @TableLogic
    @TableField("del_flag")
    protected Integer delFlag;

    /**
     * 默认的上传文件路径
     * TODO 默认配置文件路径
     */
    @TableField(exist = false)
    public final static String UPLOAD_PATH = isWindows() ? "C:/upload/mc_erp/" : "/user/upload/mc_erp/";

    public static boolean isWindows() {
        return System.getProperty("os.name").toLowerCase().contains("windows");
    }
}
